class IndexController < ApplicationController
  layout "index"
  def topten
    @result_swarm_temp=Swarm.find(:all,:conditions=>"public = 1 ").sort!{|a,b|b.user_connections.length <=> a.user_connections.length}
    
    @topten_swarm=[]
    for num in (0..9)
      @topten_swarm<<@result_swarm_temp[num]
    end
    render :layout => 'application' 
  end
  def tags
    @result_channels=Catelog.find(:all)
    
    render :layout => 'application' 
  end
  def index
    # @result_swarm=Swarm.find(:all,:conditions=>"public = 1 ",:limit=>6)
    # @result_swarm.sort!{|a,b|b.user_connections.length <=> a.user_connections.length}
    # Ezzy changes to make latest live swarms appear on TV
    
    @result_swarm_temp=Swarm.find(:all,:conditions=>"public = 1 ").sort!{|a,b|b.user_connections.length <=> a.user_connections.length}
    
    @result_swarm = []
    for num in (0..5)
      
      @result_swarm << @result_swarm_temp[num]
    end
    
    @result_channels=Catelog.find(:all)
    
    #@tags=Swarm.find_by_sql("select tags from swarms group by tags");
    
  end
end
